package com.base.util.javautils.log;

import com.orhanobut.logger.Logger;
import com.orhanobut.logger.Printer;
import com.orhanobut.logger.Settings;

/**
 * @author gj
 */
final class LogPrinter implements ILogPrinter {

    private static final String LOG_START_TAG = "--> start";

    private final Printer mPrinter;

    LogPrinter(String tag) {
        Logger.init(tag);
        mPrinter = Logger.t(tag);
        LogSettings.toDefaultSettings(this);
    }

    @Override
    public void d(String message, Object... args) {
        if (LogConfig.LOG_ON) {
            mPrinter.d(message, args);
        }
    }

    @Override
    public void e(String message, Object... args) {
        if (LogConfig.LOG_ON) {
            mPrinter.e(message, args);
        }
    }

    @Override
    public void e(Throwable throwable, String message, Object... args) {
        if (LogConfig.LOG_ON) {
            mPrinter.e(throwable, message, args);
        }
    }

    @Override
    public void w(String message, Object... args) {
        if (LogConfig.LOG_ON) {
            mPrinter.w(message, args);
        }
    }

    @Override
    public void i(String message, Object... args) {
        if (LogConfig.LOG_ON) {
            mPrinter.i(message, args);
        }
    }

    @Override
    public void v(String message, Object... args) {
        if (LogConfig.LOG_ON) {
            mPrinter.v(message, args);
        }
    }

    @Override
    public void wtf(String message, Object... args) {
        if (LogConfig.LOG_ON) {
            mPrinter.wtf(message, args);
        }
    }

    @Override
    public void json(String json) {
        if (LogConfig.LOG_ON) {
            mPrinter.json(json);
        }
    }

    @Override
    public void xml(String xml) {
        if (LogConfig.LOG_ON) {
            mPrinter.xml(xml);
        }
    }

    @Override
    public void flag() {
        if (LogConfig.LOG_ON) {
            mPrinter.i(LOG_START_TAG);
        }
    }

    public Settings getSettings() {
        return mPrinter.getSettings();
    }
}
